zoukankan      html  css  js  c++  java
  • PyCharm执行os.system出现中文乱码的问题解决方法

     1 import os,sys,io
     2 # sys.stdout = (sys.stdout.buffer,encoding='utf-8')
     3 def rule_p(n):
     4     for i in range(1,n+1):
     5         cmd_back = 'XXX' + "pfa" + str(i) + ' id ' + str(i) + ' active on'
     6         # print(cmd_back)
     7         os.system(cmd_back)
     8 n = int(input("please input a num: "))
     9 rule_p(n)
    10 print('执行完成!')
    C:UsersadminMiniconda3python.exe E:/python/rule_p.py
    please input a num: 4
    'rule' �����ڲ����ⲿ���Ҳ���ǿ����еij���
    �����������
    'rule' �����ڲ����ⲿ���Ҳ���ǿ����еij���
    �����������
    'rule' �����ڲ����ⲿ���Ҳ���ǿ����еij���
    �����������
    'rule' �����ڲ����ⲿ���Ҳ���ǿ����еij���
    �����������
    执行完成!
    
    Process finished with exit code 0

    解决办法:

    1 修改PyCharm配置:
    2 
    3 File->Settings->Editor->File Encodings
    4 
    5 把Global Encoding设置成GBK即可
  • 相关阅读:
    比较重量(网易笔试题)
    抽象工厂模式
    简单工厂模式
    R语言dai xie
    Hadoop综合大作业
    hive基本操作与应用
    用mapreduce 处理气象数据集
    熟悉常用的HBase操作,编写MapReduce作业
    爬虫大作业
    第三章 熟悉常用的HDFS操作
  • 原文地址:https://www.cnblogs.com/hujc/p/11717917.html
Copyright © 2011-2022 走看看