|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
各位大神们,我写的这个代码为什么读一个txt读出来却是一堆乱码呢
- from sys import argv
- script, filename = argv
- txt = open(filename)
- print(f"Here's your file {filename}")
- print(txt.read())
- print('Type the filename again:')
- file_again = input('>')
- txt_again = open(file_again)
- print(txt_again.read())
复制代码
- lizehongdeMacBook-Air:15_读取文件 lizehong$ python3.8 15_读取文件.py 15_text.txtHere's your file 15_text.txt
- {\rtf1\ansi\ansicpg936\cocoartf1671\cocoasubrtf600
- {\fonttbl\f0\fnil\fcharset0 Menlo-Regular;}
- {\colortbl;\red255\green255\blue255;\red0\green0\blue0;}
- {\*\expandedcolortbl;;\csgray\c0;}
- \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
- \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0
- \f0\fs22 \cf2 \CocoaLigature0 Ashhhahakhakfhliaufehi\
- fhaoiefhiofhvkdjbv\
- adaiofhoiefojireofhovih}
- Type the filename again:
- >15_text.txt
- {\rtf1\ansi\ansicpg936\cocoartf1671\cocoasubrtf600
- {\fonttbl\f0\fnil\fcharset0 Menlo-Regular;}
- {\colortbl;\red255\green255\blue255;\red0\green0\blue0;}
- {\*\expandedcolortbl;;\csgray\c0;}
- \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
- \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0
- \f0\fs22 \cf2 \CocoaLigature0 Ashhhahakhakfhliaufehi\
- fhaoiefhiofhvkdjbv\
- adaiofhoiefojireofhovih}
复制代码
|
|