2017-05-25 51 views
-2

我的教授希望我們的代碼包含一個源代碼頭,我不知道該把它放在哪裏。我究竟在哪裏放置源代碼頭?

#!/usr/bin/env python3 
# -*- coding: utf-8 -*- 
""" 
Created on Mon May 22 21:31:16 2017 

@author: noraasrar 
""" 
# Code starts here 

的源代碼頭看起來是這樣的:

########################################################### 
# Computer Project #5 
# 
# Algorithm 
# prompt for an integer 
# input an integer 
# loop while not end-of-data 
#  call function to count number of digits in integer 
#  output the number of digits 
#  prompt for an integer 
#  input an integer 
# display closing message 
########################################################### 
+2

把它放在你的教授要你把它。 – user2357112

+0

把它放在你把作者放在哪裏? – Skycc

回答

1

唯一真正的「限購」的地方,你可以把那就是前兩行的家當和行聲明編碼下方。第一行幫助您的操作系統確定如何執行該文件,第二行tells the Python executable what file encoding to use when it reads the script

由於「源代碼頭」只是一個註釋塊,這可能會工作:

#!/usr/bin/env python3 
# -*- coding: utf-8 -*- 
""" 
Created on Mon May 22 21:31:16 2017 

@author: noraasrar 
""" 
########################################################### 
# Computer Project #5 
# 
# Algorithm 
# prompt for an integer 
# input an integer 
# loop while not end-of-data 
#  call function to count number of digits in integer 
#  output the number of digits 
#  prompt for an integer 
#  input an integer 
# display closing message 
########################################################### 
# Code starts here