python语法错误常见原因_python3中open()的语法错误,不知道原因
已解決
我正在寫一本《艱難地學習Python》一書,當我試圖打開這個文件的時候,我總是遇到一個語法錯誤,我可能只是做了一些愚蠢的事情,錯過了一些顯而易見的東西,但我無法理解。非常感謝你的幫助。在from sys import argv
script, input_file = argv
def print_all(f):
print(f.read())
def rewind(f):
print(f.seek(0))
def print_a_line(line_count, f):
print(line_count, f.readline()
current_file = open("input_file")
print("First let's print the whole file: \n")
print_all(current_file)
print("Now let's rewind, kind of like a tape")
rewind(current_file)
print("Finally, let's print three lines:")
current_line = 1
print_a_line(current_line, current_file)
current_line = current_line + 1
print_a_line(current_line, current_file)
current_line = current_line + 1
print_a_line(current_line, current_file)
當我試圖聲明變量current_file并將其分配給open(“input_file”)時,出現錯誤。謝謝。在
總結
以上是生活随笔為你收集整理的python语法错误常见原因_python3中open()的语法错误,不知道原因的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tp5 excel 导入 mysql_T
- 下一篇: mysql双机数据热备份_如何设置MyS