2
當我使用指令python filename.py
的代碼,我收到以下錯誤,Python中找不到「主」模塊
/Library/anaconda/bin/python: can't find '__main__' module in filename.py
我不知道究竟是怎麼回事錯在這裏。我需要幫助解決這個問題。 我該如何解決這個問題?
SUFFIXES = {1000: ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
1024: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']}
def approximate_size(size, a_kilobyte_is_1024_bytes=True):
'''Convert a file size to human-readable form.
Keyword arguments:
size -- file size in bytes
a_kilobyte_is_1024_bytes -- if True (default), use multiples of 1024
if False, use multiples of 1000
Returns: string
'''
if size < 0:
raise ValueError('number must be non-negative')
multiple = 1024 if a_kilobyte_is_1024_bytes else 1000
for suffix in SUFFIXES[multiple]:
size /= multiple
if size < multiple:
return '{0:.1f} {1}'.format(size, suffix)
raise ValueError('number too large')
if __name__ == 「__main__」:
print(「Hello World」)
print(approximate_size(1000000000000, False))
print(approximate_size(1000000000000))
'「'是不一樣的'「'。 – roganjosh
奇怪,不過,我本來期望的錯誤是不同的TBH :) – roganjosh