ISSUE09 :: Python ‘str’ object does not support item assignment solution
Python ‘str’ object does not support item assignment solution
String immutable 하기 때문에 변경할 수 없습니다.
An Example Scenario
string = "aaaa" string[0] = "b"
이런 상황에서 발생하게 됩니다.
따라서, replace_string = "" 을 생성하고
The Solution
string = "aaaa" replace_string = "" for i in range(len(string)) : if i==0 : replace_string+="b" else : replace_string+=string[i] print(replace_string)
이런식으로 사용합니다.
Conclusion
String은 변경할 수 없기 때문에 새로운 String 변수를 생성해서 코딩하는것이 좋습니다.
'Toy-Project > ISSUE' 카테고리의 다른 글
댓글
이 글 공유하기
다른 글
-
ISSUE11 :: google.api_core.exceptions.DeadlineExceeded: 504 Deadline Exceeded
ISSUE11 :: google.api_core.exceptions.DeadlineExceeded: 504 Deadline Exceeded
2020.08.20Google Cloud Pub/Sub 을 쓰다가 해당 이슈를 만났다. 나는 PipelineOptions 에다 return_immediately=True 옵션을 주었다. 우선은 publisher 에서 topic으로 message를 전송할때 dataflow에서 pub/sub을 잘 읽어오긴한다… *ref : https://github.com/googleapis/python-pubsub/issues/36 google.api_core.exceptions.DeadlineExceeded: 504 Deadline Exceeded · Issue #36 · googleapis/python-pubsub Hi We are using google pub sub api for implementing the publisher /… -
ISSUE10 :: line 91, in finish_bundle NameError: name 'beam' is not defined During handling of the above exception, another exception occurred:
ISSUE10 :: line 91, in finish_bundle NameError: name 'beam' is not defined During handling of the above exception, another exception occurred:
2020.08.14finish_bundle_outputs File "/Users/ㅁㅁㅁㅁ/PycharmProjects/apachebeam-dataflow-project/src/main.py", line 91, in finish_bundle NameError: name 'beam' is not defined During handling of the above exception, another exception occurred: Dataflow를 실행하는 과정에서 에러가 발생하였다. beam 이라고 정의되어 있는것이 없다고 나오는데 실제로 코드상에서는 import 한 상황이다. (import apache_beam as beam) 무엇이 이슈일까? stackoverflow 를 찾아보니 다음 해결책이 있었다. 1. apache-… -
ISSUE09 :: Cannot access field name on a value with type ARRAY<STRUCT<name STRING, bytes INT64>> at [1:17]
ISSUE09 :: Cannot access field name on a value with type ARRAY<STRUCT<name STRING, bytes INT64>> at [1:17]
2020.08.11google public-data-set 에서 github의 languages 에 접근하려고 했을때 Cannot access field name on a value with type ARRAY at [1:17] 와 같은 이슈가 발생했습니다. table에서 해당 컬럼이 array 형태이기 때문에 이를 Flatten 하기 위해서 UNNEST 함수를 사용해야 합니다. select count(distinct language.name) from table -> select count(distinct n.name) from table, UNNEST(language) as n -
ISSUE08 :: python3 equivalent for auto tuple unpacking in lambda 이슈 발생 시
ISSUE08 :: python3 equivalent for auto tuple unpacking in lambda 이슈 발생 시
2020.08.10python 으로 dataflow ETL 코드를 구성하다가 lambda 로 작성되는 코드에 발생되는 이슈였습니다. lambda(x,y) : x+y 의 python3에서 auto tuple unpacking 을 lambda에서 지원해주지 않으므로 lambda x_y : x_y[0] + x_y[1] 로 작성하시면 됩니다. *ref : https://stackoverflow.com/questions/21892989/what-is-the-good-python3-equivalent-for-auto-tuple-unpacking-in-lambda
댓글을 사용할 수 없습니다.