In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
In this article, the editor introduces in detail "how to extract strings one by one in go language". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to extract strings in go language one by one" can help you solve your doubts.
Go language traverses strings-- gets each string element
Traverse every ASCII character
Traversing ASCII characters traverses using for's numeric loop, directly fetching the subscript of each string to get ASCII characters, as shown in the following example.
Package mainimport "fmt" func main () {theme: = "hello" for I: = 0; I < len (theme); iTunes + {fmt.Printf ("ascii:% c% d\ n", theme [I], theme [I])}}
The program output is as follows:
Ascii: h 104ascii: e 101ascii: l 108ascii: l 108ascii: O 111ascii: 32ascii: P 112ascii: h 104ascii: P 112ascii: ä 228ascii:, 184ascii: 173ascii: æ 230ascii: 150ascii: 135ascii: ç 231ascii: 189ascii: â 145
The Chinese characters obtained in this mode are "miserable". Because Unicode is not used, Chinese characters are displayed as garbled.
Traversing strings by Unicode character
The same content:
Package mainimport "fmt" func main () {theme: = "hello" for _, s: = range theme {fmt.Printf ("Unicode:% c% d\ n", s, s)}}
The program output is as follows:
Unicode: h 104Unicode: e 101Unicode: l 108Unicode: l 108Unicode: O 111Unicode: 32Unicode: P 112Unicode: h 104Unicode: P 112Unicode: in 20013Unicode: text 25991Unicode: net 32593, this article "how to extract strings one by one in go language" has been introduced. If you want to master the knowledge of this article, you need to practice and use it before you can understand it. If you want to know more about related articles, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.