如何在 Python 3.4 中将字符串转换为所有大写字母?
例如,我想转换:
string
Run Code Online (Sandbox Code Playgroud)
到:
STRING
Run Code Online (Sandbox Code Playgroud)
我已经尝试过该.upper方法,但它返回:
"string".upper
<built-in method upper of str object at 0x0283E860>
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
使用下面的代码我得到错误:
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'Student Data.csv'
Run Code Online (Sandbox Code Playgroud)
但如果我添加r.close()它返回我的错误:
AttributeError: '_csv.reader' object has no attribute 'close'
Run Code Online (Sandbox Code Playgroud)
键盘的代码是2580,CSV的格式是
bakerg,ict,George Baker,11HM,NORMAL
Run Code Online (Sandbox Code Playgroud)
码:
from tkinter import *
import csv
import os
login = "bakerg"
def upgradetoadmin():
global masterpassword
masterpassword = []
def one():
masterpassword.append("1")
arraycheck()
def two():
masterpassword.append("2")
arraycheck()
def three():
masterpassword.append("3")
arraycheck()
def four():
masterpassword.append("4")
arraycheck()
def five():
masterpassword.append("5")
arraycheck()
def six():
masterpassword.append("6")
arraycheck()
def seven():
masterpassword.append("7")
arraycheck() …Run Code Online (Sandbox Code Playgroud) 当我运行给定的代码时,我得到错误
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__
return self.func(*args)
File "C:\Users\Matthew\Desktop\Code\Functionised\encoder idea 2 GUI ATTEMPT.py", line 10, in encode
m = m.upper()
AttributeError: 'function' object has no attribute 'upper'
Run Code Online (Sandbox Code Playgroud)
我知道它与行有关 - m = m.upper()
但我不知道如何解决这个问题
import sys
import os.path
from tkinter import *
def encode():
array = []
temp_array = []
i = 0
m = message.get
m = m.upper()
array.append(m)
o = offset.get()
array.append(o)
length = len(array[0])
while length > …Run Code Online (Sandbox Code Playgroud)