스크립트 작업을 시도하고 있지만 한 곳에서 멈추었습니다.파일에서 백 슬래시를 이스케이프하는 방법
예 :
<?php
echo "Hello World!";
?>
그래서 내 PHP 코드가 실행되고 ....
str_php = """
<?php
echo "Hello World!";
?>"""
php_file = open("index.php", "w")
php_file.write(str_php)
php_file.close()
좋아, 내가 사용하고있는 PHP 출력을 ..받을, 그래서 그대로 내가 출력을 얻을합니다. 여기까지는 모두 좋다. 그러나, 문제는 내가
str_php = """
<?php
echo "Hello World!"; \n echo "How are you"; \n echo "God bless you";
?>"""
php_file = open("index.php", "w")
php_file.write(str_php)
php_file.close()
"\"
및 "\n"
및 "\r"
을 사용하려고 할 때부터 시작하지만, 여기에 나는 그대로 출력을 얻을니까.
<?php
echo "Hello World!";
echo "How are you";
echo "God bless you";
?>
출력에서 "\"그냥 사라집니다. 예 : 나는 PHP는 하이퍼 링크 같은 뭔가의 출력 ...
str_php = """<?php
print("<a href=\"$dirArray[$index]\">$dirArray[$index]</a>");
?>"""
php_file = open("index.php", "w")
php_file.write(str_php)
php_file.close()
내가 얻을 출력입니다 ...
<?php
print("<a href="$dirArray[$index]">$dirArray[$index]</a>");
?>
은 "\"가 실종되고 PHP 오류를 만들어 실행되지 않습니다 싶어 .
print("<a href=\"$dirArray[$index]\">$dirArray[$index]</a>") - Original
print("<a href="$dirArray[$index]">$dirArray[$index]</a>") - python output
"\", "\ n", "\ r"을 도와 줄 수 있습니까 ??
앞에서'r'을 사용하여 문자열을 선언 해 보았습니까? 'r '' '여기에 문자열을 쓰십시오.' '' ' –