0
%
을 제거하고 문자열로 바꾸고 공백을 제거하고 점수 이하로 바꾸고 싶습니다.파이썬을 사용하여 excel에서 문자열 바꾸기
이것은 내가 지금까지 무엇을했는지 있습니다 :
# Open Excel file from a user imput
import xlrd, xlwt
filename = raw_input("Enter Excel file name with extension (.xls) and path")
oldbook = xlrd.open_workbook(filename)
newbook = xlwt.Workbook()
# For all the sheets in the workbook
for sheetname in oldbook.sheet_names():
oldsheet = oldbook.sheet_by_name(sheetname)
newsheet = newbook.add_sheet(sheetname)
# For all the rows and all the columns in an excel
for ii in range(oldsheet.nrows):
for jj in range(oldsheet.ncols):
# Replace
range.replace("%", "Perc")
# Save the file in a desired location with the desired name
savelocation = raw_input("Enter a new path and file name with extension (.xls) to save the new Excel spread sheet ")
newbook.save(savelocation)
(불행하게도 나는 순간에 그것을 실행할 수 없습니다) 당신이 말한과 아무 일도하지 않기 때문에 내가 코드를 실행 :
이보십시오. 나는 오류를 얻지 않지만 그 값은 대체되지 않습니다. – user256683
그래서 스프레드 시트 사본을 얻을 수 있습니까? – hstay
예 모든 숫자가 문자열로되어있는 스프레드 시트를 얻지 만 변경되지 않았습니다. %는 여전히 기호이고 Excel의 빈 칸은 밑줄로 표시되지 않습니다. – user256683