在php中压缩字符串并在python中解压缩

时间:2019-01-11 17:37:13

标签: php python compression gz

我在PHP中具有以下代码:

package webDrivertests;

// import statements

public class Methods {

    public static WebDriver driver;

    public void launchBrowser() {

         System.setProperty("webdriver.chrome.driver","C:\\chromedriver_win32\\chromedriver.exe");
        System.setProperty("webdriver.chrome.args", "--disable-logging");
        System.setProperty("webdriver.chrome.silentOutput", "true");
        driver = new ChromeDriver();
    }

    public void goToURL(String url) {
        driver.get(url);
    }

        public void enterValue(String htmltype, String identifier, String value) throws InterruptedException {
        if (htmltype == "id") {
            WebElement element = driver.findElement(By.id(identifier));
            element.clear();
            element.sendKeys(value);
            element.submit();
        }
        if (htmltype =="name") {
            WebElement element = driver.findElement(By.name(identifier));
            element.clear();
            element.sendKeys(value);
            element.submit();
        }

        Thread.sleep(3000);
    }

}

然后在python中,我有以下代码:

$text = gzcompress($text);
// send $text to a python server

但是这失败了,因为解压缩功能需要字节,而我正在向它传递一个字符串。有谁知道如何解压缩用php压缩的python中的字符串?

PS:我对特定的算法或功能并不特别感兴趣。

0 个答案:

没有答案