简体   繁体   中英

Python with open using pycharm doesn't do what i want

I am trying to open a file and print it's contents.

with open('pi_digits.txt') as file_object:
    contents = file_object.read()
    print(contents)

I am using PyCharm and i have my txt file in the same folder as my project. The txt file just has pi with 30 decimals.

The output i am expecting is:

3.1415926535
  8979323846
  2643383279

But instead i get nothing. What am i doing wrong?

Oké so my previous python file was still set to run so the python file with the code i wanted to run, wasn't running. After i set my new file to run it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM