이 코드에서 스크립트는 "Base.txt" 파일 에서 모든 좌표 (x, y)를 가져 오지만 안타깝게도 결과는 1 번 줄에서만 "Save.txt" 파일에 저장 하고 나머지 좌표 선은 건너 뜁니다. 목록의 값.
from ecpy.curves
import Curve,Point
with open("Base.txt", "rt") as base:
for line in base.read().splitlines():
x, y = map(lambda v: int(v, 16), line[1: -1].split(" , "))
cv = Curve.get_curve('secp256k1')
A = Point(x,y,cv)
C = 6
B = A*C
with open("Save.txt", "w") as file:
print(B,file=file, sep="\n")
목록의 모든 결과를 "Save.txt" 파일에 어떻게 저장합니까?
for 루프
with open("Base.txt", "rt") as base:
for line in base.read().splitlines():
x, y = map(lambda v: int(v, 16), line[1: -1].split(" , "))
덮어 쓰기 x
및 y
각 라인. for 루프에 모든 것을 포함하고 파일을 '추가'모드로 열고 파일에서 write
함수를 사용해야 합니다.
from ecpy.curves
import Curve,Point
with open("Base.txt", "rt") as base:
for line in base.read().splitlines():
x, y = map(lambda v: int(v, 16), line[1: -1].split(" , "))
cv = Curve.get_curve('secp256k1')
A = Point(x,y,cv)
C = 6
B = A*C
with open("Save.txt", "a") as file:
file.write(str(B)) # should implement the __str__ or __repr__ method
file.write("\n")
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다