character

'characters is unavailable' please use string directly

帅比萌擦擦* 提交于 2020-01-30 06:42:07
问题 I can't figure out how to fix it. I just want to understand how it works and what should be replaced. I've already tried to delete characters. , but it still doesn't work. import Foundation var shrinking = String("hello") repeat { print(shrinking) shrinking = String(shrinking.characters.dropLast()) } while shrinking.characters.count > 0 I expected the program to output: hello hell hel he h but it doesn't work at all. 回答1: Your code should work as it is if you delete the characters I suggest

'characters is unavailable' please use string directly

吃可爱长大的小学妹 提交于 2020-01-30 06:41:51
问题 I can't figure out how to fix it. I just want to understand how it works and what should be replaced. I've already tried to delete characters. , but it still doesn't work. import Foundation var shrinking = String("hello") repeat { print(shrinking) shrinking = String(shrinking.characters.dropLast()) } while shrinking.characters.count > 0 I expected the program to output: hello hell hel he h but it doesn't work at all. 回答1: Your code should work as it is if you delete the characters I suggest

PHP Echoing JSON string into HTML Input value - Need character escape

烂漫一生 提交于 2020-01-30 05:21:24
问题 Here is a simplified version of my code that I am having a problem with. $variable = "{\\\"JSON" //long JSON string created in Javascript with JSON.stringify ?> <input type="text" name="somename" value="<?php echo $variable; ?>"/> <?php The input box only contains {\ I need a way to escape the entire JSON string Thanks Alex 回答1: You're outputting into an HTML context, so you need html-specific escaping: <input ... value="<?php echo htmlspecialchars(json_encode($whatever)); ?>" /> ^^^^^^^^^^^^

R: Encode character variables into numeric

我的梦境 提交于 2020-01-29 23:28:52
问题 In R code I have a character variable var that has values "AA", "AB", "AC", etc. str(var) chr [1:17003] "AA" "AA" "AA" "AA" "AB" "AB" ... How can I convert it to numeric variable so that "AA" would be coded as, e.g. 1, "AB" - as 2, etc. 回答1: You can convert the string to a factor and then to numeric. x <- c("AA", "AB", "AB", "AC", "AA", "XY") as.numeric(as.factor(x)) # [1] 1 2 2 3 1 4 Alternatively, you can use match and unique : match(x, unique(x)) # [1] 1 2 2 3 1 4 回答2: you can use them by

Replacing all occurrences of a pattern in a string

耗尽温柔 提交于 2020-01-28 05:11:59
问题 Used to run R with numbers and matrix, when it comes to play with strings and characters I am lost. I want to analyze some data where the time is read into R as follow: >my.time.char[1] [1] "\"2011-10-05 15:55:00\"" I want to end up with a string containing only: "2011-10-05 15:55:00" Using the function sub() (that i barely understand...), I got the following result: > sub("(\")","",my.time.char[1]) [1] "2011-10-05 15:55:00\"" This is closer to the format i am looking for, but I still need to

Pygame: Character not appearing on screen

杀马特。学长 韩版系。学妹 提交于 2020-01-26 03:54:07
问题 I have been trying to get this code to work for weeks and cannot figure out the issue. I have a list of images, that I am using to animate my character. THe game worked fine at first, but ever since I made the background animate (start moving left to right), my character stopped appearing. Do I have to change the location of some of my code? Really confused. Thank you!! # create lists with images of character walking left and right rightDirection = [pygame.image.load('R1.png'), pygame.image

how do i connect a page to a button - pygame?

僤鯓⒐⒋嵵緔 提交于 2020-01-25 10:12:18
问题 I have a menu with 3 buttons. I want one of the buttons to connect to my game page which I have but am not sure how to make this happen. So I want the "game" button to lead to the screen which has the actual game (like the screen where you play the game). i am trying to figure out how to connect a page to a button in this pygame. Thanks # import images background = pygame.image.load('background.png') backgroundX = 0 backgroundX2 = background.get_width() homeScreen = pygame.image.load('home

Match character placeholders (places where an input cursor can be putted)

若如初见. 提交于 2020-01-25 07:22:12
问题 I work with Visual Studio Code and I have a problem with a 1,000 lines long .md document in which generally each line contains one or more sentence. I desire to wrap each sentence with vertical bars (one from the left and one from the right, with respective empty spaces), for the process of transforming the long list of sentences into a (single columned) markdown table. Current input sentence Desired input | Sentence | or: | Sentence. Sentence | and so on... How I thought to do it In general,

Transform to numeric a column with “NULL” values

為{幸葍}努か 提交于 2020-01-24 21:22:26
问题 I've imported a dataset into R where in a column which should be supposed to contain numeric values are present NULL . This make R set the column class to character or factor depending on if you are using or not the stringAsFactors argument. To give you and idea this is the structure of the dataset. > str(data) 'data.frame': 1016 obs. of 10 variables: $ Date : Date, format: "2014-01-01" "2014-01-01" "2014-01-01" "2014-01-01" ... $ Name : chr "Chi" "Chi" "Chi" "Chi" ... $ Impressions: chr

Emacs lisp: Translate characters to standard ASCII transcription

北城以北 提交于 2020-01-24 08:45:27
问题 I am trying to write a function, that translates a string containing unicode characters into some default ASCII transcription. Ideally I'd like e.g. Ångström to become Angstroem or, if that is not possible, Angstrom . Likewise α=χ should become a=x (c?) or similar. Does Emacs have such built-in capabilities? I know I can get the names and similar of characters ( get-char-code-property ) but I know no built-in transcription table. The purpose is to translate titles of entries into meaningfully